package com.demo.inject.static_factory;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestMyBeanFactory {
    @Test
    public void test1(){
        UserService userService=MyBeanFactory.createService();
        userService.addUser();
    }
    
    //spring工厂
    @Test
    public void test2(){
        String xmlPath="inject/static_factory/beans.xml";
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext(xmlPath);
        UserService userService=applicationContext.getBean("userService",UserService.class);
        userService.addUser();
    }
}
